package com.ybkj.daijia.server.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.springframework.util.CollectionUtils;

/**
 * 重量阶段
 *
 * @author Shine
 */
public class ChargeStartWeight implements Serializable {

    private static final long serialVersionUID = 1L;
    private Long id;
    private Date created;
    private Date updated;
    private Integer startWeight;// 开始重量

    private Integer addWeight;// 重量阈值

    private Integer overWeight;// 超过重量

    private BigDecimal cost;// 加收费用

    private List<ChargeWeightDistance> chargeWeightDistance;

    private Long areaId;


    public Integer getStartWeight() {
        return startWeight;
    }

    public void setStartWeight(Integer startWeight) {
        this.startWeight = startWeight;
    }

    public Integer getAddWeight() {
        return addWeight;
    }

    public void setAddWeight(Integer addWeight) {
        this.addWeight = addWeight;
    }

    public Integer getOverWeight() {
        return overWeight;
    }

    public void setOverWeight(Integer overWeight) {
        this.overWeight = overWeight;
    }

    public BigDecimal getCost() {
        return cost;
    }

    public void setCost(BigDecimal cost) {
        this.cost = cost;
    }

    public List<ChargeWeightDistance> getChargeWeightDistance() {
        return chargeWeightDistance;
    }

    public void setChargeWeightDistance(
        List<ChargeWeightDistance> chargeWeightDistance) {
        this.chargeWeightDistance = chargeWeightDistance;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Long getAreaId() {
        return areaId;
    }

    public void setAreaId(Long areaId) {
        this.areaId = areaId;
    }

    public List<ChargeWeightDistance> getChargeWeightDistances() {
        if (!CollectionUtils.isEmpty(chargeWeightDistance)) {
//			Collections.sort(chargeStartDistances, new Comparator<ChargeStartDistance>() {
//	            public int compare(ChargeStartDistance arg0, ChargeStartDistance arg1) {
//	                return arg0.getDistance().compareTo(arg1.getDistance());
//	            }
//	        });

            for (int i = 0; i < chargeWeightDistance.size(); i++) {
                if (i == 0) {
                    chargeWeightDistance.get(i).setStartdistance(0d);
                } else {
                    chargeWeightDistance.get(i)
                        .setStartdistance(chargeWeightDistance.get(i - 1).getDistance());
                }
            }

        }

        return chargeWeightDistance;
    }

    public boolean isEmpty() {
        if (null != startWeight && null != addWeight) {
            return false;
        }
        return true;
    }

}
